<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="资产编码">
              <a-input placeholder="请输入资产编码" v-model="queryParam.assetCode"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="资产类别">
              <j-dict-select-tag placeholder="请选择资产类别" v-model="queryParam.assetClass" dictCode="zcgl_asset_classify" />
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="资产名称">
                <a-input placeholder="请输入资产名称" v-model="queryParam.assetName"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="产权单位">
                <a-input placeholder="请输入产权单位" v-model="queryParam.propertyRightUnit"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="合同编号">
                <a-input placeholder="请输入合同编号" v-model="queryParam.contractNum"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="客户名称">
                <a-input placeholder="请输入客户名称" v-model="queryParam.name"></a-input>
              </a-form-item>
            </a-col>
            <!--            <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
            <!--              <a-form-item label="产权证编号">-->
            <!--                <a-input placeholder="请输入产权证编号" v-model="queryParam.propertyRightCode"></a-input>-->
            <!--              </a-form-item>-->
            <!--            </a-col>-->
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="状态">
                <j-dict-select-tag placeholder="请选择状态" v-model="queryParam.status" dictCode="zcgl_asset_status" />
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="是否欠费">
                <j-dict-select-tag placeholder="请选择是否欠费" v-model="queryParam.isArrears" dictCode="yn" />
              </a-form-item>
            </a-col>
            <!--<a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="土地性质">
                <j-dict-select-tag placeholder="请选择土地性质" v-model="queryParam.landStatus"
                                   dictCode="zcgl_asset_soiltype"/>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="房屋性质">
                <j-dict-select-tag placeholder="请选择房屋性质" v-model="queryParam.roomType" dictCode="zcgl_asset_housetype"/>
              </a-form-item>
            </a-col>-->
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <!--      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>-->
      <a-button v-has="'assetLedger:export'" type="primary" icon="download" @click="handleExportXls('资产台账')">导出
      </a-button>
<!--      <a-upload v-has="'assetLedger:import'" name="file" :showUploadList="false" :multiple="false"-->
<!--                :headers="tokenHeader" :action="importExcelUrl"-->
<!--                @change="handleImportExcel">-->
<!--        <a-button type="primary" icon="import">导入</a-button>-->
<!--      </a-upload>-->
      <!--      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importXlsDictUrl"-->
      <!--                @change="handleImportExcel">-->
      <!--        <a-button type="primary" icon="import">导入a</a-button>-->
      <!--      </a-upload>-->
<!--      <a-button v-has="'assetLedger:temp'" type="primary" icon="download" @click="handleExportXlsTemplate('资产台账模板')">-->
<!--        模板下载-->
<!--      </a-button>-->
      <!--      <a-dropdown v-if="selectedRowKeys.length > 0">-->
      <!--        <a-menu slot="overlay">-->
      <!--          <a-menu-item key="1" @click="batchDel">-->
      <!--            <a-icon type="delete"/>-->
      <!--            删除-->
      <!--          </a-menu-item>-->
      <!--        </a-menu>-->
      <!--        <a-button style="margin-left: 8px"> 批量操作-->
      <!--          <a-icon type="down"/>-->
      <!--        </a-button>-->
      <!--      </a-dropdown>-->
    </div>

    <!-- table区域-begin -->
    <div>
      <!--      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">-->
      <!--        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{-->
      <!--        selectedRowKeys.length }}</a>项-->
      <!--        <a style="margin-left: 24px" @click="onClearSelected">清空</a>-->
      <!--      </div>-->

      <a-table
        ref="table"
        size="middle"
        bordered
        :scroll="{ x: 5000, y: screenHeight }"
        rowKey="id"
        class="j-table-force-wrap"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">
        <!--
                rowKey="assetSubId"
                :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"-->

        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="uploadFile(text)">
            下载
          </a-button>
        </template>

      </a-table>
    </div>

    <assetInfo-modal ref="modalForm" @ok="modalFormOk"></assetInfo-modal>
    <assetInfoDisposal-modal ref="modalDisposalForm" @ok="modalDisposalOk"></assetInfoDisposal-modal>
  </a-card>
</template>

<script>

import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import AssetInfoModal from './modules/AssetInfoModal'
import AssetInfoDisposalModal from './modules/AssetInfoDisposalModal'
import JDictSelectTag from '@/components/dict/JDictSelectTag.vue'
import { filterMultiDictText } from '@/components/dict/JDictSelectUtil'
import JInput from '@/components/jeecg/JInput'
import '@/assets/less/TableExpand.less'

export default {
  name: 'AssetLedgerList',
  mixins: [JeecgListMixin],
  components: {
    JInput,
    JDictSelectTag,
    AssetInfoDisposalModal,
    AssetInfoModal
  },
  data () {
    return {
      description: '资产台账',
      // 表头
      columns: [
        {
          title: '序号',
          dataIndex: 'rowIndex',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          fixed: 'left',
          customRender: (text, record, index) =>
            `${(this.ipagination.current - 1) * this.ipagination.pageSize + index + 1}`
        },
        {
          title: '合同编号',
          align: 'center',
          // fixed:"left",
          // width: 200,
          // ellipsis: true,
          dataIndex: 'contractNum'
        },
        {
          title: '资产编码',
          align: 'center',
          dataIndex: 'assetCode'
        },
        {
          title: '资产类别',
          align: 'center',
          dataIndex: 'assetClass_dictText'
        },
        {
          title: '资产名称',
          align: 'center',
          dataIndex: 'assetName'
        },
        {
          title: '门牌号',
          align: 'center',
          // fixed:"left",
          // width: 200,
          dataIndex: 'roomName'
        },
        {
          title: '产权单位',
          align: 'center',
          dataIndex: 'propertyRightUnit'
        },
        {
          title: '产权证编号',
          align: 'center',
          dataIndex: 'propertyRightCode'
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'status_dictText'
          // customRender: function (t, r, index) {
          //   if (r.status == 40) {
          //     return t + '（' + r.assetDisposal_dictText + '）'
          //   }
          //   return t
          // }
        },
        // {
        //   title: '上会时间',
        //   align: 'center',
        //   dataIndex: 'meetingTime'
        // },
        {
          title: '坐落位置',
          align: 'center',
          // width: 200,
          dataIndex: 'site'
        },
        {
          title: '产权证地址',
          align: 'center',
          dataIndex: 'addressPropertyDivision'
        },
        {
          title: '产权面积（m²）',
          align: 'center',
          dataIndex: 'propertyRightArea'
        },
        {
          title: '出租面积',
          align: 'center',
          dataIndex: 'rentableArea'
        },
        {
          title: '土地面积(亩)',
          align: 'center',
          dataIndex: 'landArea'
        },
        {
          title: '土地面积(平方)',
          align: 'center',
          dataIndex: 'landAreaSquare'
        },
        {
          title: '共有面积(平方)',
          align: 'center',
          dataIndex: 'totalArea'
        },
        {
          title: '承租人',
          align: 'center',
          // fixed:"left",
          // width: 200,
          dataIndex: 'name'
        },
        {
          title: '身份证号/信用代码',
          align: 'center',
          // fixed:"left",
          // width: 200,
          dataIndex: 'code'
        },
        {
          title: '经营业态',
          align: 'center',
          dataIndex: 'manageStatus'
        },
        {
          title: '商户名称',
          align: 'center',
          dataIndex: 'merchantName'
        },
        {
          title: '租金单价（元）',
          align: 'center',
          dataIndex: 'rentPrice',
          customRender: function (text) {
            if (!text) {
              text = 0
            }
            return text.toLocaleString('zh-Hans-CN', { style: 'currency', currency: 'CNY' })
          }
        },
        {
          title: '月租金（元）',
          align: 'center',
          dataIndex: 'monthlyRent',
          customRender: function (text) {
            if (!text) {
              text = 0
            }
            return text.toLocaleString('zh-Hans-CN', { style: 'currency', currency: 'CNY' })
          }
        },
        {
          title: '保证金（元）',
          align: 'center',
          dataIndex: 'cashDeposit',
          customRender: function (text) {
            if (!text) {
              text = 0
            }
            return text.toLocaleString('zh-Hans-CN', { style: 'currency', currency: 'CNY' })
          }
        },
        {
          title: '合同租金浮动比例',
          align: 'center',
          dataIndex: 'contractChangeRatio',
          customRender: function (text) {
            return !text ? '' : text.toFixed(4)
          }
        },
        {
          title: '起租时间',
          align: 'center',
          dataIndex: 'rentStartTime',
          customRender: function (text) {
            return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
          }
        },
        {
          title: '到租时间',
          align: 'center',
          dataIndex: 'rentEndTime',
          customRender: function (text) {
            return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
          }
        },
        {
          title: '合同期限',
          align: 'center',
          dataIndex: 'contractPeriod'
        },
        {
          title: '租金支付方式',
          align: 'center',
          dataIndex: 'modeOfPayment_dictText'
        },
        {
          title: '联系电话',
          align: 'center',
          dataIndex: 'phone'
        },
        // {
        //   title: '联系人',
        //   align: 'center',
        //   dataIndex: 'contactPerson'
        // },
        {
          title: '缴费截止日期',
          align: 'center',
          dataIndex: 'paymentDeadline'
        },
        {
          title: '是否欠费',
          align: 'center',
          dataIndex: 'isArrears_dictText'
        },
        {
          title: '欠费金额',
          align: 'center',
          dataIndex: 'oweAmount',
          customRender: function (text) {
            if (!text) {
              text = 0
            }
            return text.toLocaleString('zh-Hans-CN', { style: 'currency', currency: 'CNY' })
          }
        },
        {
          title: '管理人员',
          align: 'center',
          dataIndex: 'managerId_dictText'
        },
        {
          title: '备注',
          align: 'center',
          dataIndex: 'remark'
        },
        {
          title: '价值（万元）',
          align: 'center',
          dataIndex: 'worth',
          customRender: function (text) {
            if (!text) {
              text = 0
            }
            return text.toLocaleString('zh-Hans-CN', { style: 'currency', currency: 'CNY' })
          }
        },
        {
          title: '空置原因',
          align: 'center',
          dataIndex: 'emptyReason'
        },
        {
          title: '具体问题',
          align: 'center',
          dataIndex: 'concreteIssue'
        },
        {
          title: '是否有产权',
          align: 'center',
          dataIndex: 'isProperty_dictText'
        },
        {
          title: '管区',
          align: 'center',
          dataIndex: 'regional_dictText'
        },
        {
          title: '原管理单位',
          align: 'center',
          dataIndex: 'originalManagementUnit'
        },
        {
          title: '原产权单位',
          align: 'center',
          dataIndex: 'originalPropertyRightUnit'
        },
        {
          title: '批复文号',
          align: 'center',
          dataIndex: 'approvalDocumentNumber'
        },
        {
          title: '调拔时间',
          align: 'center',
          dataIndex: 'pullTime'
        }
      ],
      url: {
        list: '/zcgl/statisticalReport/assetLedger',
        exportXlsUrl: '/zcgl/statisticalReport/assetLedger/exportXls',
        importXlsDictUrl: '/zcgl/statisticalReport/dict/importExcel',
        importExcelUrl: 'zcgl/statisticalReport/assetLedger/importExcel',
        exportXlsTemplate: 'zcgl/statisticalReport/assetLedger/exportXlsTemplate'
      },
      dictOptions: {}
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
    importXlsDictUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importXlsDictUrl}`
    }
  },
  methods: {
    initDictConfig(){
      this.addColumns()
    },
    modalDisposalOk () {
      this.loadData()
    }

  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>